import Opt from '@/components/dt/info/Opt.js'
import table from '@/components/dt/table/render.js'
let _this = null
class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
    {
      title: "公司",
      field: "caseLocationTwo",
      minWidth: 140,
    },
    {
      title: "所属城市",
      field: "city",
      minWidth: 100,
    },
    {
      title: "案场名称",
      field: "housesName",
      minWidth: 160,
    },
    {
      title: "产品类型",
      field: "productType",
      minWidth: 90,
      cell: {
        text: {
          type: 'dict',
          key: 'productType'
        }
      }
    },
    {
      title: "提交时间",
      field: "submitTime",
      minWidth: 180,
    },
    {
      title: "审核结果",
      field: "approveStatus",
      minWidth: 110,
      cell: {
        text: {
          type: 'dict',
          key: 'buildingApproveStatus'
        }
      },
      header: {
        filter: {
          title: '审核结果',
          key: 'approveStatus',
          placeholder: '选择审核结果',
          select: {
            options: _this.$dt.dictInfo().buildingApproveStatus,
          }
        }
      }
    },
    {
      title: "审核人",
      field: "auditName",
      minWidth: 110,
    },
    {
      title: "审核时间",
      field: "auditTime",
      minWidth: 180,
      header: {
        filter: {
          title: '审核时间',
          key: 'time',
          placeholder: '请选择时间',
          date: {
            type: 'daterange',
          },
          data: {
            to: (v) => {
              return {
                startTime: v[0],
                endTime: v[1]
              }
            }
          }
        }
      }
    },
    {
      title: "操作",
      field: "result",
      minWidth: 100,
      fixed: 'right',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'getPreSaleRec',
            data: [params.row, '0']
          })

          btns.push({
            title: params.row.approveStatus == "0" && _this.unlocking(
                '0206020101') ?
              '审核' : '',
            event: 'getPreSaleRec',
            data: [params.row, '1']
          })

          return table.cell.btns(_this, h, btns)
        }
      }
    }, ]
  }

}

export default Column